package bookExercise;

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;

public class A14Grouping {
    public static void main(String[] args) {
        List<A14Emplyee> list = A14Emplyee.getEmpList();
        Map<String, List<A14Emplyee>> collect = list.stream()
                .collect(Collectors.groupingBy(A14Emplyee::getDept));
        Set<String> strings = collect.keySet();
        for (String string : strings) {
            System.out.println("【"+string+"】");
            List<A14Emplyee> a14Emplyees = collect.get(string);
            for (A14Emplyee a14Emplyee : a14Emplyees) {
                System.out.println(a14Emplyee);
            }
        }

    }
}
